#include "Patch.h"

Patch::Patch(){
	topLeft = topRight = bottomLeft = bottomRight = Point3(0,0,0);
	radiantEnergy = MyColor(0,0,0,1);
	illuminance = MyColor(0,0,0,1);
	area = 0;
}

Patch::Patch(Point3 _topLeft, Point3 _bottomLeft, Point3 _bottomRight, Point3 _topRight){
	radiantEnergy = MyColor(0,0,0,1);
	illuminance = MyColor(0,0,0,1);
	setPoints(_topLeft, _bottomLeft, _bottomRight, _topRight);
}

void Patch::setPoints(Point3 _topLeft, Point3 _bottomLeft, Point3 _bottomRight, Point3 _topRight){
	topLeft = _topLeft;
	topRight = _topRight;
	bottomLeft = _bottomLeft;
	bottomRight = _bottomRight;

	midpoint.x = topLeft.x + (bottomRight.x - topLeft.x)/2.0;
	midpoint.y = topLeft.y + (bottomRight.y - topLeft.y)/2.0;
	midpoint.z = topLeft.z + (bottomRight.z - topLeft.z)/2.0;

	area = (topRight-topLeft).length()*(bottomLeft-topLeft).length();
}